<?php
/**
 * 分销管理
 */


defined('In33hao') or exit('Access Invalid!');

class fenxiaoControl extends SystemControl
{
    public function __construct()
    {
        parent::__construct();
    }

    public function indexOp()
    {
        $model_setting = Model('setting');
        if (chksubmit()) {
            $update_array['fx_hy_share'] = $_POST['fx_hy_share'];
            $update_array['fx_hy_brand'] = $_POST['fx_hy_brand'];
            $update_array['fx_hy_level_two'] = $_POST['fx_hy_level_two'];
            $update_array['fx_hy_level_one'] = $_POST['fx_hy_level_one'];
            $result = $model_setting->updateSetting($update_array);
            if ($result === true) {
                $this->log(L('nc_edit,fenxiao'), 1);
                showMessage('设置成功');
            } else {
                $this->log(L('nc_edit,fenxiao'), 0);
                showMessage('设置失败');
            }
        }
        $list_setting = $model_setting->getListSetting();
        Tpl::output('list_setting', $list_setting);
        Tpl::setDirquna('system');
        Tpl::showpage('fenxiao.index');
    }

    public function agentOp()
    {
        $model_setting = Model('setting');
        if (chksubmit()) {
            $update_array['fx_dl_city'] = $_POST['fx_dl_city'];
            $update_array['fx_dl_area'] = $_POST['fx_dl_area'];
            $update_array['fx_dl_area_invite'] = $_POST['fx_dl_area_invite'];
            $update_array['fx_dl_city_invite'] = $_POST['fx_dl_city_invite'];
            $update_array['fx_dl_ty'] = $_POST['fx_dl_ty'];
            $update_array['fx_dl_ty_invite'] = $_POST['fx_dl_ty_invite'];
            $update_array['fx_dl_ty_one'] = $_POST['fx_dl_ty_one'];
            $result = $model_setting->updateSetting($update_array);
            if ($result === true) {
                $this->log(L('nc_edit,fenxiao'), 1);
                showMessage('设置成功');
            } else {
                $this->log(L('nc_edit,fenxiao'), 0);
                showMessage('设置失败');
            }
        }
        $list_setting = $model_setting->getListSetting();
        Tpl::output('list_setting', $list_setting);
        Tpl::setDirquna('system');
        Tpl::showpage('fenxiao.agent');
    }

    public function sqOp()
    {
        $model_setting = Model('setting');
        if (chksubmit()) {
            $update_array['fx_sq_hy'] = $_POST['fx_sq_hy'];
            $update_array['fx_sq_hy_one'] = $_POST['fx_sq_hy_one'];
            $update_array['fx_sq_hy_two'] = $_POST['fx_sq_hy_two'];
            $update_array['fx_sq_sh_one'] = $_POST['fx_sq_sh_one'];
            $update_array['fx_sq_sh_two'] = $_POST['fx_sq_sh_two'];
            $result = $model_setting->updateSetting($update_array);
            if ($result === true) {
                $this->log(L('nc_edit,fenxiao'), 1);
                showMessage('设置成功');
            } else {
                $this->log(L('nc_edit,fenxiao'), 0);
                showMessage('设置失败');
            }
        }
        $list_setting = $model_setting->getListSetting();
        Tpl::output('list_setting', $list_setting);
        Tpl::setDirquna('system');
        Tpl::showpage('fenxiao.sq');
    }

    public function storeOp()
    {
        $model_setting = Model('setting');
        if (chksubmit()) {
            $update_array = [
                'fx_st_tc_one'         => $_POST['fx_st_tc_one'],
                'fx_st_one_open_one'   => $_POST['fx_st_one_open_one'],
                'fx_st_one_open_two'   => $_POST['fx_st_one_open_two'],
                'fx_st_one'            => $_POST['fx_st_one'],
                'fx_st_point_one'      => $_POST['fx_st_point_one'],
                'fx_st_one_invite'     => $_POST['fx_st_one_invite'],
                'fx_st_cash_one'       => $_POST['fx_st_cash_one'],

                'fx_st_tc_two'         => $_POST['fx_st_tc_two'],
                'fx_st_two_open_one'   => $_POST['fx_st_two_open_one'],
                'fx_st_two_open_two'   => $_POST['fx_st_two_open_two'],
                'fx_st_two'            => $_POST['fx_st_two'],
                'fx_st_point_two'      => $_POST['fx_st_point_two'],
                'fx_st_two_invite'     => $_POST['fx_st_two_invite'],
                'fx_st_cash_two'       => $_POST['fx_st_cash_two'],

                'fx_st_tc_three'       => $_POST['fx_st_tc_three'],
                'fx_st_three_open_one' => $_POST['fx_st_three_open_one'],
                'fx_st_three_open_two' => $_POST['fx_st_three_open_two'],
                'fx_st_three'          => $_POST['fx_st_three'],
                'fx_st_point_three'    => $_POST['fx_st_point_three'],
                'fx_st_three_invite'   => $_POST['fx_st_three_invite'],
                'fx_st_cash_three'     => $_POST['fx_st_cash_three'],

                'fx_st_tc_four'        => $_POST['fx_st_tc_four'],
                'fx_st_four_open_one'  => $_POST['fx_st_four_open_one'],
                'fx_st_four_open_two'  => $_POST['fx_st_four_open_two'],
                'fx_st_four'           => $_POST['fx_st_four'],
                'fx_st_point_four'     => $_POST['fx_st_point_four'],
                'fx_st_four_invite'    => $_POST['fx_st_four_invite'],
                'fx_st_cash_four'      => $_POST['fx_st_cash_four'],
            ];
            $result = $model_setting->updateSetting($update_array);
            if ($result === true) {
                $this->log(L('nc_edit,fenxiao'), 1);
                showMessage('设置成功');
            } else {
                $this->log(L('nc_edit,fenxiao'), 0);
                showMessage('设置失败');
            }
        }
        $list_setting = $model_setting->getListSetting();
        Tpl::output('list_setting', $list_setting);
        Tpl::setDirquna('system');
        Tpl::showpage('fenxiao.store');
    }
}
